
pkgname=nfs-utils
pkgver=2.3.1
pkgrel=1
pkgdesc="Support programs for Network File Systems"
arch=('x86_64')
url='http://nfs.sourceforge.net'
license=('GPL')
backup=(etc/{exports,nfs.conf,nfsmount.conf})
depends=('glibc' 'e2fsprogs' 'rpcbind' 'libtirpc' 'librpcsecgss' 'libevent'
         'device-mapper' 'sqlite')
makedepends=('pkgconfig' 'autoconf' 'automake' 'nfsidmap')
conflicts=('nfsidmap')
provides=('nfsidmap')
replaces=('nfsidmap')
source=("https://downloads.sourceforge.net/project/nfs/nfs-utils/${pkgver}/${pkgname}-${pkgver}.tar.bz2"
        'exports'
        'id_resolver.conf')
md5sums=('913141ab49421ceb8dc98336b1ec7fda'
         'e6ad3c7a59c7e4c24965a0e7da35026c'
         '391aaafdf01a665629c708d1386b5896')

build() {
  cd ${pkgname}-${pkgver}
  
  ./configure --prefix=/usr \
    --enable-nfsv4 \
    --enable-nfsv41 \
    --enable-gss \
    --without-tcp-wrappers \
    --with-statedir=/var/lib/nfs \
    --enable-ipv6 \
    --sysconfdir=/etc \
    --enable-libmount-mount \
    --without-gssglue \
    --enable-mountconfig 
  make 
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install

  install -D -m 644 utils/mount/nfsmount.conf ${pkgdir}/etc/nfsmount.conf
  install -D -m 644 nfs.conf ${pkgdir}/etc/nfs.conf

  # systemd files
  for i in systemd/{*.service,*.mount,*.target}; do
    install -D -m 644 $i ${pkgdir}/usr/lib/systemd/system/$(basename $i)
  done
  
  install -d -m 644 ${pkgdir}/usr/share/doc/${pkgname}
  install -m 644 NEWS ${pkgdir}/usr/share/doc/${pkgname}/
  install -m 644 README ${pkgdir}/usr/share/doc/${pkgname}/
  
  cd ..
  install -D -m 644 exports          ${pkgdir}/etc/exports
  install -D -m 644 id_resolver.conf ${pkgdir}/etc/request-key.d/id_resolver.conf
  
  mkdir ${pkgdir}/etc/exports.d
  mkdir -m 555 ${pkgdir}/var/lib/nfs/rpc_pipefs
  mkdir ${pkgdir}/var/lib/nfs/v4recovery
}

